<template>
<div>
    <div v-show="showviewHouse==0" class="houseManage-view">
        <div><TissueTree></TissueTree></div>
        <div class="organization-content-list">
            <div class="content-cotent">
                <div class="content-title">
                    <div class="title">{{organizationName}}</div>
                    <div>商品：{{totalpag}}</div>
                </div>
                <div class="cotent-botton">
                    <div class="cotent-botton-input">
                        <el-select v-model="province" value-key="id" clearable placeholder="省">
                            <el-option
                                    v-for="item in citylist"
                                    :key="item.id"
                                    :label="item.name"
                                    :value="item">
                            </el-option>
                        </el-select>
                    </div>
                    <div class="cotent-botton-input">
                        <el-select v-model="city" value-key="id" clearable placeholder="市">
                            <el-option
                                    v-for="item in citylist1"
                                    :key="item.id"
                                    :label="item.name"
                                    :value="item">
                            </el-option>
                        </el-select>
                    </div>
                    <div class="cotent-botton-input">
                        <el-select v-model="area" value-key="id" clearable placeholder="区/县">
                            <el-option
                                    v-for="item in citylist2"
                                    :key="item.id"
                                    :label="item.name"
                                    :value="item">
                            </el-option>
                        </el-select>
                    </div>
                    <div class="cotent-botton-input">
                        <el-select v-model="value5" clearable placeholder="是否启用">
                            <el-option
                                    v-for="item in options1"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </div>
                    <div class="cotent-botton-botton-one" @click="queryInfo">查 询</div>
                    <div class="cotent-botton-botton-two" @click="emptyingInfo">清 空</div>
                </div>
                <div class="cotent-botton">
                    <div class="cotent-botton-botton-one" @click="addHouseinit" >
                        新增
                    </div>
                    <div class="cotent-botton-botton-two" @click="deletDetails">删 除</div>
                    <div class="cotent-botton-botton-two2" @click="importHouse(1)">
                        批量编辑
                    </div>
                    <div class="cotent-botton-botton-two2" @click="exportHouse">
                        批量导出
                    </div>
                    <div class="cotent-botton-botton-two" @click="frameType(0)" >上 架</div>
                    <div class="cotent-botton-botton-two" @click="frameType(1)">下 架</div>
                    <div class="cotent-botton-botton-two2" @click="price(2)">
                        批量设置开通价格
                    </div>
                    <div class="cotent-botton-botton-two2" @click="price(1)">
                        VIP价格设置
                    </div>
                    <div class="cotent-botton-botton-two2" @click="sleeve">
                        套盘价格设置
                    </div>
                    <div class="cotent-botton-botton-two2" @click="distribution">
                        分配驻场
                    </div>
                    <div class="cotent-botton-botton-two2" @click="commission">
                        批量设置佣金
                    </div>
                    <!--<el-popover-->
                            <!--placement="bottom"-->
                            <!--width="641"-->
                            <!--trigger="click">-->
                        <!--<el-checkbox-group v-model="checkList" >-->
                            <!--<el-checkbox class="cotent-botton-botton-checkbox"  label="复选框 A"></el-checkbox>-->
                            <!--<el-checkbox class="cotent-botton-botton-checkbox"  label="复选框 B"></el-checkbox>-->
                            <!--<el-checkbox class="cotent-botton-botton-checkbox"  label="复选框 C"></el-checkbox>-->
                            <!--<el-checkbox class="cotent-botton-botton-checkbox"  label="禁用no" ></el-checkbox>-->
                            <!--<el-checkbox class="cotent-botton-botton-checkbox"  label="禁用no" ></el-checkbox>-->
                            <!--<el-checkbox class="cotent-botton-botton-checkbox"  label="禁用no" ></el-checkbox>-->
                            <!--<el-checkbox class="cotent-botton-botton-checkbox"  label="禁用no" ></el-checkbox>-->
                            <!--<el-checkbox class="cotent-botton-botton-checkbox"  label="禁用no" ></el-checkbox>-->
                            <!--<el-checkbox class="cotent-botton-botton-checkbox"  label="禁用no" ></el-checkbox>-->
                            <!--<el-checkbox class="cotent-botton-botton-checkbox"  label="禁用no" ></el-checkbox>-->
                            <!--<el-checkbox class="cotent-botton-botton-checkbox"  label="禁用no" ></el-checkbox>-->
                            <!--<el-checkbox class="cotent-botton-botton-checkbox"  label="禁用no" ></el-checkbox>-->
                        <!--</el-checkbox-group>-->
                        <!--<el-button class="cotent-botton-botton-checkbox-button" slot="reference"><i class="el-icon-menu"></i></el-button>-->
                    <!--</el-popover>-->
                </div>
            </div>

            <div>
                <linkerList :headlist="headlist" :contentlist="list" @selectList="selectList" @houseViewShow="houseViewShow" @houseViewShowedit="addeidtHouseinit"></linkerList>
                <Pagination :totalpag="totalpag" v-on:currentpage="currentpage"></Pagination>
            </div>
        </div>
    </div>
    <!--<div v-show="showviewHouse==1">-->
       <!--<addHouse @coloeHouseViewShow="coloeHouseViewShow" :seeHouseId="seeHouseId"></addHouse>-->
    <!--</div>-->
    <!--<div v-show="showviewHouse==2">-->
        <!--<seeHouse @coloeHouseViewShow="coloeHouseViewShow" :seeHouseId="seeHouseId"></seeHouse>-->
    <!--</div>-->
    <distributionStationing :dialogFormVisible="distributionBox" @refreshList="refreshList" @close="closeDistribution" :linkerIds="selectLists"></distributionStationing>
    <commissionSet :dialogFormVisible="commissionBox" @refreshList="refreshList" @close="closeCommission" :linkerIdString="selectLists"></commissionSet>
    <priceSet :dialogFormVisible="priceSetBox" @close="closepriceSetBox" :priceSetType="priceSetType" :linkerIds="selectLists"></priceSet>
    <priceSleeveSet :selectLinkerId="selectLinkerId" :dialogFormVisible="sleeveBox" @close="closesleeveBox" :linkerIds="selectLists"></priceSleeveSet>
    <importHouse :dialogFormVisible="dialogFormVisibleimport" @close="closeFormImport" :importHouseType="importHouseType"  @refreshList="getlist"></importHouse>
</div>
</template>

<script>
    import importHouse from '../common/Dialog/importHouse';
    import TissueTree from '../common/TissueTree';
    import linkerList from '../common/user/linkerList';
    import Pagination from '../common/Pagination';
    import addHouse from '../common/house/addHouse';
    import seeHouse from '../common/house/seeHouse';
    import distributionStationing from '../common/house/distributionStationing';
    import commissionSet from '../common/house/commissionSet';
    import priceSet from '../common/house/priceSet';
    import priceSleeveSet from '../common/house/priceSleeveSet';
    import {isUseAble,organType} from "../../utils/constant";
    export default {
        name: "houseManage",
        data(){
            return{
                importHouseType:0,
                dialogFormVisibleimport:false,
                organizationName:this.$store.getters.userData.userMsg.name,//组织id
                selectLinkerId:"",
                organizationId: this.$store.getters.userData.userMsg.id,//组织id
                priceSetType:0,
                sleeveBox:false,
                distributionBox:false,
                commissionBox:false,
                priceSetBox:false,
                showviewHouse:0,
                selectLists:"",
                province:"",
                city:"",
                area:"",
                citylist:[],
                citylist1:[],
                citylist2:[],
                seeHouseId:"",
               checkList: ['复选框 A'],
                options: [{
                    value: '0',
                    label: '代理商'
                }, {
                    value: '1',
                    label: '开发商'
                }, {
                    value: '2',
                    label: '平台'
                }, {
                    value: '3',
                    label: '中介'
                }, {
                    value: '4',
                    label: '职能部门'
                }],
                options1:[{
                    value: '1',
                    label: '已启用'
                },{
                    value: '0',
                    label: '已停用'
                }],
                value4: '',
                value5: '',
                headlist:{
                    checkout:true,
                    operation:{
                        type:true,
                        fromurl:"houseManage",
                    },
                    list:[
                        {
                            prop:"objectName",
                            label:"名称",
                            width:"200",
                        },{
                            prop:"fyType",
                            label:"分类",
                            width:"130",
                        }
                        ,{
                            prop:"region",
                            label:"所在地址",
                            width:"180",
                        }
                        ,{
                            prop:"averagePrice",
                            label:"价格",
                            width:"110",
                        }
                        ,{
                            prop:"houseUse",
                            label:"物业类型",
                            width:"130",
                        }
                        ,{
                            prop:"shelfFlag",
                            label:"上架状态",
                            width:"130",
                        }
                        ,{
                            prop:"name",
                            label:"驻场",
                            width:"120",
                        }
                        ,{
                            prop:"divisionRules",
                            label:"佣金",
                            width:"130",
                        }
                    ]},
                list:[],
                totalpag:0,
                current:1,
            }
        },
        components: {
            TissueTree,
            linkerList,
            Pagination,
            addHouse,
            seeHouse,
            distributionStationing,
            commissionSet,
             priceSet,
            priceSleeveSet,
            importHouse
        },
        watch: {

            province(){
                console.log(this.province,"}}}}}}}}}}")
                this.city=""
                if(this.province){
                    let _this = this;
                    let params={
                        pid:this.province.id,
                    }
                    _this.Api.setting.cityList(params).then((data)=>{
                        console.log("kkkkkkkkkkkkkkkkkkk",data)
                        _this.citylist1=data.data;
                    })
                }

            },
            city(){
                console.log(this.city,"}}}}}}}}}}")
                this.area=""
                if(this.city){
                    let _this = this;
                    let params={
                        pid:this.city.id,
                    }
                    _this.Api.setting.cityList(params).then((data)=>{
                        console.log("kkkkkkkkkkkkkkkkkkk",data)
                        _this.citylist2=data.data;
                    })
                }

            },
        },
        mounted(){
            this.getlist();
            this.getcity();
        },
        methods: {
            //批量导出
            exportHouse(){
                let _this = this;
                let params={
                    distributorId:this.organizationId,//分销商id
                    province:this.province.name,
                    city:this.city.name,
                    county:this.area.name,
                    shelfFlag:this.value5,
                }
                _this.Api.setting.distNewHousesAllExportExcel(params).then((data)=>{
                   console.log("mmmmmmmmmmmmmmm",data)
                })
            },
            //批量导入用户
            importHouse(type){
                this.importHouseType=type
                this.dialogFormVisibleimport=true
            },
            closeFormImport(){
                this.dialogFormVisibleimport=false
            },
            //刷新列表，供子组件调用的父组件刷新列表方法
            refreshList() {
                this.getlist();
            },

            //打开套盘
            sleeve(){
                this.sleeveBox=true
            },
            closesleeveBox(){
                this.sleeveBox=false
            },
            //分配驻场
            distribution(){
                if(this.selectLists){
                    this.distributionBox=true
                }else {
                    this.$alert('您还没勾选操作内容', '温馨提示', {
                        confirmButtonText: '确定',
                        callback: action => {
                            this.$message({
                                type: 'info',
                                message: `action: ${ action }`
                            });
                        }
                    });
                }

            },
            //关闭分配驻场
            closeDistribution(){
                this.distributionBox=false
            },
            //设置佣金
            commission(){
                if(this.selectLists){
                    this.commissionBox=true
                }else {
                    this.$alert('您还没勾选操作内容', '温馨提示', {
                        confirmButtonText: '确定',
                        callback: action => {
                            this.$message({
                                type: 'info',
                                message: `action: ${ action }`
                            });
                        }
                    });
                }

            },
            //关闭佣金
            closeCommission(){
                this.commissionBox=false
            },
            //开启价格设置
            price(type){
                if (type==2) {
                    if(this.selectLists){
                        this.priceSetType=type
                        this.priceSetBox=true
                    }else {
                        this.$alert('您还没勾选操作内容', '温馨提示', {
                            confirmButtonText: '确定',
                            callback: action => {
                                this.$message({
                                    type: 'info',
                                    message: `action: ${ action }`
                                });
                            }
                        });
                    }
                }else {
                    this.priceSetType=type
                    this.priceSetBox=true
                }


            },
            //关闭价格设置
            closepriceSetBox(){
                this.priceSetBox=false
            },
            //删除
            selectList(val){
                this.selectLists=val
                console.log(val,"内容内容内容")
            },
            //删除
            deletDetails(){
                if(this.selectLists){
                    this.$confirm('确定要删除内容吗？', '确认', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                    }).then(() => {
                        let _this = this;
                        let params={
                            linkerIds:this.selectLists,
                        }
                        console.log("ssssssssssssssssssssss",this.selectLists)
                        _this.Api.setting.distDeleteAllNewHouse(params).then((data)=>{
                            this.getlist();
                            this.$message({
                                message: "删除内容成功",
                                type: 'success'
                            });
                        })
                    }).catch(() => {

                    });

                }else {
                    this.$alert('您还没勾选删除内容', '温馨提示', {
                        confirmButtonText: '确定',
                        callback: action => {
                            this.$message({
                                type: 'info',
                                message: `action: ${ action }`
                            });
                        }
                    });
                }
                console.log("删除的",this.selectLists)
            },
            //上下架
            frameType(type){
                if(this.selectLists){
                    this.$confirm('确定要操作内容吗？', '确认', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                    }).then(() => {
                        let _this = this;
                        let params={
                            shelfFlag:type,
                            linkerIds:this.selectLists,
                        }
                        _this.Api.setting.distUpdateAllHouseShelfFlag(params).then((data)=>{
                            //刷新列表
                            this.getlist();
                            this.$message({
                                message: "操作成功",
                                type: 'success'
                            });
                        })
                    }).catch(() => {

                    });

                }else {
                    this.$alert('您还没勾选操作内容', '温馨提示', {
                        confirmButtonText: '确定',
                        callback: action => {
                            this.$message({
                                type: 'info',
                                message: `action: ${ action }`
                            });
                        }
                    });
                }
                console.log("删除的",this.selectLists)
            },
            //查询
            queryInfo(){
                if (this.province==""&&this.city==""&&this.area==""&&this.value5=="") {
                    this.$message({
                        message: '没有输入或选择查询内容',
                        type: 'warning'
                    });
                }else {
                    this.getlist()
                }
            },
            //清空
            emptyingInfo(){
                this.province="";
                this.city="";
                this.area="";
                this.value5="";
                this.getlist();
            },
            //获取城市
            getcity(){
                let _this = this;
                let params={
                    pid:0,
                }
                _this.Api.setting.cityList(params).then((data)=>{
                    console.log("kkkkkkkkkkkkkkkkkkk",data)
                    _this.citylist=data.data;
                })
            },
            // coloeHouseViewShow(){
            //     this.showviewHouse=0;
            // },
            houseViewShow(val){
                console.log(">>>>>>>>>>来来阿莱",val)
                this.$router.push({path: './seeHouse',query: {seeHouseId: val}});
            },
            //到新增页面
            addHouseinit(){
                // this.showviewHouse=1;
                this.$router.push({path: './addHouse',query: {type:"add"}});
            },
            //到编辑页面
            addeidtHouseinit(val){
                // this.showviewHouse=1;
                this.$router.push({path: './addHouse',query: {linkerId: val,type:"edit"}});
            },
            selectList(val){
                this.selectLists=val
            },
            currentpage(currentpage){
                console.log("当前页，",currentpage)
                this.current=currentpage
                this.getlist()
            },
            getlist(){
                let _this = this;
                let params={
                    current:_this.current,
                    size:10,
                    distributorId:this.organizationId,//分销商id
                    province:this.province.name,
                    city:this.city.name,
                    county:this.area.name,
                    shelfFlag:this.value5,
                }
                _this.Api.setting.distNewHouses(params).then((data)=>{
                    _this.totalpag=data.data.total;
                    _this.list=data.data.records;
                })
            },
        }
    }
</script>

<style scoped rel="stylesheet/scss" lang="scss">
.houseManage-view{
        display: flex;
        .organization-content-list {
            margin: 20px;
            .content-cotent {
                background-color: #ffffff;
                padding: 24px 32px;
                .content-title {
                    display: flex;
                    div {
                        font-size: 14px;
                        font-family: PingFangSC-Regular;
                        font-weight: 400;
                        color: rgba(51, 51, 51, 0.85);
                        line-height: 22px;
                        margin-right: 16px;
                    }
                    .title {
                        font-size: 20px;
                        font-family: PingFangSC-Medium;
                        font-weight: 500;
                        color: rgba(0, 0, 0, 0.85);
                    }
                }
            }
            .cotent-botton{
                display: flex;
                margin-top: 24px;
                .cotent-botton-input{
                    width:200px;
                    height:32px;
                    margin-right: 16px;

                }
                .cotent-botton-botton-one{
                    width:65px;
                    height:32px;
                    line-height: 32px;
                    text-align: center;
                    background:rgba(24,144,255,1);
                    border-radius:4px;
                    font-size:14px;
                    font-family:PingFangSC-Regular;
                    font-weight:400;
                    color:rgba(255,255,255,1);
                    margin-right: 16px;
                    cursor: pointer;
                }
                .cotent-botton-botton-two{
                    width:65px;
                    height:32px;
                    line-height: 32px;
                    background:rgba(255,255,255,1);
                    border-radius:4px;
                    border:1px #D9D9D9 solid;
                    font-size:14px;
                    font-family:PingFangSC-Regular;
                    font-weight:400;
                    color:rgba(0,0,0,0.65);
                    text-align: center;
                    margin-right: 16px;
                    cursor: pointer;
                }
                .cotent-botton-botton-two2{
                    padding: 0px 16px;
                    height:32px;
                    line-height: 32px;
                    background:rgba(255,255,255,1);
                    border-radius:4px;
                    border:1px #D9D9D9 solid;
                    font-size:14px;
                    font-family:PingFangSC-Regular;
                    font-weight:400;
                    color:rgba(0,0,0,0.65);
                    text-align: center;
                    margin-right: 16px;
                    cursor: pointer;
                }

            }

        }
}
.cotent-botton-botton-checkbox{
    font-size:14px;
    font-family:PingFangSC-Regular;
    font-weight:400;
    color:rgba(0,0,0,0.65);
    line-height:22px;
    width: 106.83px;
    margin-left: 7px;
    margin-right: 5px;
    margin-top: 10px;
}
    .cotent-botton-botton-checkbox-button{
        color: #BFBFBF;
        border:1px #D9D9D9 solid;
        font-size: 14px;
        display: flex;
        width:46px;
        height:32px;
        i{
        }
    }
</style>